package br.com.nooclix.salon.infrastructure;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.nooclix.salon.domain.service.Service;
import br.com.nooclix.salon.domain.service.ServiceRepository;

public class ServiceRepositoryImpl extends
		AbstractRepositoryImpl<Service, Integer> implements ServiceRepository {

	public ServiceRepositoryImpl() {
		super(Service.class);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public List<Service> findByNameService(String name) {
		Criteria criteria = getSession().createCriteria(entityClass);

		criteria.add(Restrictions.ilike("name", name, MatchMode.ANYWHERE));

		return criteria.list();
	}
}
